const app = new BasicTableVue({
    data() {
        return {
            api: tlogSystemApi,
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                new TableColumn({prop: 'level', title: '级别', customComponent: true}),
                new TableColumn({prop: 'actTime', title: '发生时间', formatter: TableColumn.datetimeFormat}),
                new TableColumn({prop: 'location', title: '请求地址'}),
                new TableColumn({prop: 'processId', title: '进程号'}),
                new TableColumn({prop: 'sourceIp', title: '来源IP'}),
                new TableColumn({prop: 'message', title: '消息'}),
                new TableColumn({prop: 'operating', title: '查看', customComponent: true}),

            ],
            //级别， 1：信息，2：警告，3：错误
            levelMap: [
                {'id': '1', 'name': '信息'},
                {'id': '2', 'name': '警告'},
                {'id': '3', 'name': '错误'},
            ],
            /**
             * 级别类型列表， 1：信息，2：警告，3：错误
             */
            levelList: {'1': '信息', '2': '警告', '3': '错误'},
            /**
             * 小图标
             * '1':'信息','2':'警告','3':'错误'
             */
            logIconImgList: {'1': 'logicon_info.gif', '2': 'logicon_warning.gif', '3': 'logicon_err.gif'},
        }
    },
    methods: {
        imgUrl: function (val) {
            return '/static/img/' + this.logIconImgList[val]
        },
        createForm() {
            return new TlogSystemVo()
        },
        timeChange(timeArray) {
            var startTime = '';
            var endTime = '';
            if (timeArray) {
                startTime = timeArray[0];
                endTime = timeArray[1];
            }
            this.form.startTime = startTime;
            this.form.endTime = endTime;
            this.searchPage();
        },
        async init() {
            const isfromSub = forward.getData().isfromSub
            if (isfromSub) {
                var page = forward.getData().page
                var entity = forward.getData().entity
                this.page.current = page.current
                this.page.size = page.size
                this.form = entity
                this.searchPage()
            }

            var isFromAdminSecurity = forward.getData().isFromAdminSecurity
            if (isFromAdminSecurity) {
                var matchQuery = forward.getData().matchQuery
                this.page.current = 1
                this.page.size = 10
                this.form.matchQuery = matchQuery
                console.info(this.form)
                this.searchPage()

            }
        },

        viewInfo(row) {
            const pagestartIndex = (this.page.current - 1) * this.page.size
            const endIndex = this.page.total - 1
            forward('/security-log/see/admin_security_syslogdetail', {
                id: row.id,
                page: this.page,
                entity: this.form,
                pagestartIndex: pagestartIndex,
                endIndex: endIndex,
            })

        },

    },


})
